Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

306
Visualizações
What is "elementHandle.contentFrame()" in PlayWright?

I just solved a problem using "elementHandle.contentFrame()", but not really know what's going on behind it. So, I was trying to select a DOM element and click on it. But I realized that I couldn't just simply do it like this when the element is wrapped inside a frame:

{
    await page.click('<element>');
}

So, I applied this method ("elementHandle.contentFrame()") and it works!

{
    const handle = await page.$('frame');
    const contentFrame = await handle.contentFrame();

    await contentFrame.click('<selector>');
}

Can someone explain to me the concept behind it? Thanks!

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You don't have to use contentFrame, page.frame('frame-name') can give you a frame instance as well.

Basically you can think iframe is a page inside another page, so that you have to first find that frame if you want select the element inside a iframe

about 4 years ago · Juan Pablo Isaza Relatório

0

The handle you have in the handle variable represents iframe element inside the page. With that variable, you can read or manipulate that element in the same way you can do with any other DOM element on that page. But you can't access the HTML content that iframe rendered.

That's why, if you want to interact with the content inside that frame you need to get the frame using contentFrame.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda